var config = {
    // URL: "http://10.1.1.215:8080/jsite-szy-dispatch/a/",
    URL: "http://123.85.3.50:9004/jsite-szy-dispatch/a/",
    RIVER: sessionStorage.RIVER ? sessionStorage.RIVER : "02", //ajax请求中参数加入river: '02' (抚河'02',袁河'03')用来切换抚河/袁河两条河流,
    contaminantsTrackEvenCd: '', //应急事件跳转污染追踪溯源时保存应急事件编号
    waterQualityProCd: '', //应急方案跳转水质模拟时保存应急方案编号
    newPlanProCd: '', //应急方案跳转水量调度时保存应急方案编号
    proType: "0",
    // defaultEndDate: new Date(),
    // defaultStartDate: new Date(new Date().getTime() - 7*24*60*60*1000),
    defaultStartDate: moment()
        .subtract(7, "day")
        .format("YYYY-MM-DD"),
    defaultEndDate: moment().format("YYYY-MM-DD"),
    getSelectData: function(type) {
        var _dictList = dictList || [];
        var result = [];
        _dictList.forEach(function(item) {
            if (item.type === type) {
                result.push(item);
            }
        });
        return result;
    }
};
/**
 * 过滤字典获取对应的值
 * @param  {String} type  字典类型
 * @param  {Strign} value 字典类型值
 * @return {Object}       匹配对象
 */
function getValue(type, value) {
    var _dictList = dictList || [];
    for (var i = 0; i < _dictList.length; i++) {
        if (_dictList[i].type == type && _dictList[i].value == value) {
            return _dictList[i].label || "";
        }
    }
}

function getRnm(rcd) {
    if (!rcd) { return " "; }
    var _dictList = mriverList || [];
    for (var i = 0; i < _dictList.length; i++) {
        if (_dictList[i].rcd == rcd) {
            return _dictList[i].rnm || " ";
        }
    }
}
// 设置默认请求参数
$.ajaxSetup({
    data: {
        "river": config.RIVER
    }
});

// math.config({
//   number: 'BigNumber'
// });

// 常规调度配置
jQuery.dispatch = {
    dtype: '',
    year: { // 常规调度年调度方案
        proCd: '',
        edit: false
    },
    month: { // 常规调度月调度方案
        proCd: '',
        edit: false
    },
    xun: { // 常规调度旬调度方案
        proCd: '',
        edit: false
    },
    getDtype: function() {
        return this.dtype;
    },
    getProCd: function() {
        if (typeof this[this.dtype] === 'object') {
            return this[this.dtype].proCd;
        }
        return '';
    },
    getEdit: function() {
        if (typeof this[this.dtype] === 'object') {
            return this[this.dtype].edit;
        }
        //         return '';
        //     },
        //     setType: function(value) {
        //         var year = 'year';
        //         var month = 'month';
        //         var xun = 'xun';
        //         if (value === year) {
        //             this.dtype = year;
        //         } else if (value === month) {
        //             this.dtype = month;
        //         } else if (value === xun) {
        //             this.dtype = xun;
        //         }
        //     },
        //     setYearProCd: function(value) {
        //         this.year.proCd = value;
        //     },
        //     setMonthProCd: function(value) {
        //         this.month.proCd = value;
        //     },
        //     setXunProCd: function(value) {
        //         this.xun.proCd = value;
        //     },
        //     setYearEdit: function(value) {
        //         this.year.edit = value;
        //     },
        //     setMonthEdit: function(value) {
        //         this.month.edit = value;
        //     },
        //     setXunEdit: function(value) {
        //         this.xun.edit = value;
        //     }
        // };
        return '';
    },
    setType: function(value) {
        const year = 'year';
        const month = 'month';
        const xun = 'xun';
        if (value === year) {
            this.dtype = year;
        } else if (value === month) {
            this.dtype = month;
        } else if (value === xun) {
            this.dtype = xun;
        }
    },
    setYearProCd: function(value) {
        this.year.proCd = value;
    },
    setMonthProCd: function(value) {
        this.month.proCd = value;
    },
    setXunProCd: function(value) {
        this.xun.proCd = value;
    },
    setYearEdit: function(value) {
        this.year.edit = value;
    },
    setMonthEdit: function(value) {
        this.month.edit = value;
    },
    setXunEdit: function(value) {
        this.xun.edit = value;
    },
    componentQuery: function(xtype) {
        var type = this.getDtype();
        var queryHead = '';
        if ('year' === type) {
            queryHead = 'yearDispatch ';
        } else if ('month' === type) {
            queryHead = 'monthDispatch ';
        } else if ('xun' === type) {
            queryHead = 'xunDispatch ';
        }
        var components = Ext.ComponentQuery.query(queryHead + xtype);
        if (components.length > 0) {
            return components[0];
        }
        return undefined;
    }
};

var RIVER_DATA = {
    "02": {
        name: "抚河"
    },
    "03": {
        name: "袁河"
    }
};